<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<html>
<%@ include file="../inc/Title.jsp"%>
<head>
<script src="/calendar/calendar.js"></script>
<script language="javascript">
	function checkInput(){
		if(window.event.keyCode==13){
			doOk();
		}
	}
	function doOk(){
		var str="search_type=1";
		
		if(document.getElementById("cb_order_date").checked){
			var startDate=document.getElementById("start_date").value;
			if(startDate==null || startDate==''){
				alert("请选择订货开始日期");
				return;
			}else{
				var arr=startDate.split("-");
				if(arr.length==null || arr.length!=3){
					alert("订货开始日期格式不正确");
					return;
				}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
					alert("订货开始日期格式不正确");
					return;
				}
			}
			var endDate=document.getElementById("end_date").value;
			if(endDate==null || endDate==''){
				alert("请选择订货结束日期");
				return;
			}else{
				var arr=endDate.split("-");
				if(arr.length==null || arr.length!=3){
					alert("订货结束日期格式不正确");
					return;
				}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
					alert("订货结束日期格式不正确");
					return;
				}
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_order_date=1&start_date="+startDate+"&end_date="+endDate;
		}
		if(document.getElementById("cb_examine").checked){
			var examined="A";
			if(document.getElementById("examine1").checked){
				examined="Y";
			}else if(document.getElementById("examine2").checked){
				examined="N";
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_examine=1&examined="+examined;
		}
		if(document.getElementById("cb_complete").checked){
			var completed="A";
			if(document.getElementById("complete1").checked){
				completed="Y";
			}else if(document.getElementById("complete2").checked){
				completed="N";
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_complete=1&completed="+completed;
		}
		if(document.getElementById("cb_close").checked){
			var closed="A";
			if(document.getElementById("close1").checked){
				closed="Y";
			}else if(document.getElementById("close2").checked){
				closed="N";
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_close=1&closed="+closed;
		}
		if(document.getElementById("cb_manager").checked){
			var managerName=document.getElementById("manager_name").value;
			if(managerName==null || managerName==""){
				alert("请输入经办人姓名");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_manager=1&manager_name="+encodeURIComponent(managerName);
		}
		if(document.getElementById("cb_est").checked){
			var estName=document.getElementById("est_name").value;
			if(estName==null || estName==""){
				alert("请输入订货单位");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_est=1&est_name="+encodeURIComponent(estName);
		}
		if(document.getElementById("cb_bill_code").checked){
			var billCode=document.getElementById("bill_code").value;
			if(billCode==null || billCode==""){
				alert("请输入业务单号");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_bill_code=1&bill_code="+encodeURIComponent(billCode);
		}
		if(document.getElementById("cb_dep").checked){
			var department=document.getElementById("department").value;
			if(department==null || department=="" || department=="0"){
				alert("请选择部门");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_dep=1&department="+department;
		}
		if(document.getElementById("cb_cost").checked){
			var minCost=document.getElementById("min_cost").value;
			if(minCost==null || minCost==""){
				alert("请输入最小金额");
				return;
			}else if(isNaN(minCost)){
				alert("最小金额只能是数字");
				return;
			}
			var maxCost=document.getElementById("max_cost").value;
			if(maxCost==null || maxCost==""){
				alert("请输入最大金额");
				return;
			}else if(isNaN(maxCost)){
				alert("最大金额只能是数字");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_cost=1&min_cost="+minCost+"&max_cost="+maxCost;
		}
		if(document.getElementById("cb_designer").checked){
			var designerName=document.getElementById("designer_name").value;
			if(designerName==null || designerName==""){
				alert("请输入设计人姓名");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_designer=1&designer_name="+encodeURIComponent(designerName);
		}
		if(document.getElementById("cb_cont_code").checked){
			var contCode=document.getElementById("cont_code").value;
			if(contCode==null || contCode==""){
				alert("请输入合同号");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_cont_code=1&cont_code="+encodeURIComponent(contCode);
		}
		if(document.getElementById("cb_ts").checked){
			var tsId=document.getElementById("ts_id").value;
			if(tsId==null || tsId=="" || tsId=="0"){
				alert("请选择帐套");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_ts=1&ts_id="+tsId;
		}
		window.location="/business/BusinessBillSearchResult.ihtm?"+str;
	}
	function doCancel(){
		window.close();
	}
	function checkCbChange(obj){
		if(obj.id=="cb_order_date"){
			if(obj.checked){
				document.getElementById("start_date").disabled=false;
				document.getElementById("end_date").disabled=false;
			}else{
				document.getElementById("start_date").disabled=true;
				document.getElementById("end_date").disabled=true;
			}
		}else if(obj.id=="cb_examine"){
			if(obj.checked){
				document.getElementById("examine1").disabled=false;
				document.getElementById("examine2").disabled=false;
				document.getElementById("examine3").disabled=false;
			}else{
				document.getElementById("examine1").disabled=true;
				document.getElementById("examine2").disabled=true;
				document.getElementById("examine3").disabled=true;
			}
		}else if(obj.id=="cb_complete"){
			if(obj.checked){
				document.getElementById("complete1").disabled=false;
				document.getElementById("complete2").disabled=false;
				document.getElementById("complete3").disabled=false;
			}else{
				document.getElementById("complete1").disabled=true;
				document.getElementById("complete2").disabled=true;
				document.getElementById("complete3").disabled=true;
			}
		}else if(obj.id=="cb_close"){
			if(obj.checked){
				document.getElementById("close1").disabled=false;
				document.getElementById("close2").disabled=false;
				document.getElementById("close3").disabled=false;
			}else{
				document.getElementById("close1").disabled=true;
				document.getElementById("close2").disabled=true;
				document.getElementById("close3").disabled=true;
			}
		}else if(obj.id=="cb_manager"){
			if(obj.checked){
				document.getElementById("manager_name").disabled=false;
			}else{
				document.getElementById("manager_name").disabled=true;
			}
		}else if(obj.id=="cb_est"){
			if(obj.checked){
				document.getElementById("est_name").disabled=false;
			}else{
				document.getElementById("est_name").disabled=true;
			}
		}else if(obj.id=="cb_bill_code"){
			if(obj.checked){
				document.getElementById("bill_code").disabled=false;
			}else{
				document.getElementById("bill_code").disabled=true;
			}
		}else if(obj.id=="cb_dep"){
			if(obj.checked){
				document.getElementById("department").disabled=false;
			}else{
				document.getElementById("department").disabled=true;
			}
		}else if(obj.id=="cb_cost"){
			if(obj.checked){
				document.getElementById("min_cost").disabled=false;
				document.getElementById("max_cost").disabled=false;
			}else{
				document.getElementById("min_cost").disabled=true;
				document.getElementById("max_cost").disabled=true;
			}
		}else if(obj.id=="cb_designer"){
			if(obj.checked){
				document.getElementById("designer_name").disabled=false;
			}else{
				document.getElementById("designer_name").disabled=true;
			}
		}else if(obj.id=="cb_cont_code"){
			if(obj.checked){
				document.getElementById("cont_code").disabled=false;
			}else{
				document.getElementById("cont_code").disabled=true;
			}
		}else if(obj.id=="cb_ts"){
			if(obj.checked){
				document.getElementById("ts_id").disabled=false;
			}else{
				document.getElementById("ts_id").disabled=true;
			}
		}
	}
</script>
</head>
<body oncontextmenu="return false">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td align="center" valign="top">
			
			<c:set var="pageTopTitle" value="业务单查询" />
			<c:set var="pageTopMark" value="通过业务单查询，可以对业务单进行编辑、打印，查看业务单的状态、收款记录、制作记录、送货记录等" />
			<%@ include file="../inc/PageTop.jsp"%>
			
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center" class="ListTable">
				<tr class="ListTr">
					<td width="1" class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_order_date" id="cb_order_date" checked="true" onClick="checkCbChange(this);">
					</td>
					<td width="80" class="ListTd FontSmall_Bold">
						订货日期
					</td>
					<td class="ListTd FontSmall">
						从<input type="text" maxlength="15" onKeyUp="checkInput();" id="start_date" name="start_date" value="${start_date}">
						<img src="/images/calendar.gif" style="cursor:hand" onClick="fPopUpCalendarDlg('/calendar/','start_date');">
						至<input type="text" maxlength="15" onKeyUp="checkInput();" id="end_date" name="end_date" value="${end_date}">
						<img src="/images/calendar.gif" style="cursor:hand" onClick="fPopUpCalendarDlg('/calendar/','end_date');">
						（格式：2008-01-01）
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_examine" id="cb_examine" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						审核状态
					</td>
					<td class="ListTd FontSmall">
						<input type="radio" name="examined" id="examine1" checked="true" disabled="true">已审核
						<input type="radio" name="examined" id="examine2" disabled="true">未审核
						<input type="radio" name="examined" id="examine3" disabled="true">全部
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_complete" id="cb_complete" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						完工状态
					</td>
					<td class="ListTd FontSmall">
						<input type="radio" name="completed" id="complete1" checked="true" disabled="true">已完工
						<input type="radio" name="completed" id="complete2" disabled="true">未完工
						<input type="radio" name="completed" id="complete3" disabled="true">全部
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_close" id="cb_close" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						结清状态
					</td>
					<td class="ListTd FontSmall">
						<input type="radio" name="closed" id="close1" disabled="true">已结清
						<input type="radio" name="closed" id="close2" checked="true"  disabled="true">未结清
						<input type="radio" name="closed" id="close3" disabled="true">全部
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_manager" id="cb_manager" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						经办人员
					</td>
					<td class="ListTd FontSmall">
						<input type="text" maxlength="15" name="manager_name" id="manager_name" onKeyUp="checkInput();" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_est" id="cb_est" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						订货单位
					</td>
					<td class="ListTd FontSmall">
						<input type="text" maxlength="50" name="est_name" id="est_name" onKeyUp="checkInput();" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_bill_code" id="cb_bill_code" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						业务单号
					</td>
					<td class="ListTd FontSmall">
						<input type="text" maxlength="50" name="bill_code" id="bill_code" onKeyUp="checkInput();" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_dep" id="cb_dep" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						部门
					</td>
					<td class="ListTd FontSmall">
						<select name="department" id="department" disabled="true">
							<option value="0">==请选择==</option>
			  				<commonTag:createSelectTree list="${departmentList}" emptyOption="0" />
			  			</select>
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_cost" id="cb_cost" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						订货金额
					</td>
					<td class="ListTd FontSmall">
						从<input type="text" maxlength="15" onKeyUp="checkInput();" id="min_cost" name="min_cost" disabled="true">
						至<input type="text" maxlength="15" onKeyUp="checkInput();" id="max_cost" name="max_cost" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_designer" id="cb_designer" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						设计人员
					</td>
					<td class="ListTd FontSmall">
						<input type="text" maxlength="15" name="designer_name" id="designer_name" onKeyUp="checkInput();" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_cont_code" id="cb_cont_code" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						合同号
					</td>
					<td class="ListTd FontSmall">
						<input type="text" maxlength="50" name="cont_code" id="cont_code" onKeyUp="checkInput();" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_ts" id="cb_ts" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						账套
					</td>
					<td class="ListTd FontSmall">
						<select name="ts_id" id="ts_id" disabled="true">
							<option value="0">==请选择==</option>
							<c:forEach var="item" items="${tsList}">
								<option value="${item.id}">${item.title}</option>
							</c:forEach>
			  			</select>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td height="10" align="center">
			<table width="98%" border="0" cellpadding="0" cellspacing="0">
				<tr><td align="center" bgcolor="#666666" height="1"></td></tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr class="ListTr">
					<td>
						<input type="button" class="Button" value=" 确 定 " onClick="doOk();">
						<input type="button" class="Button" value=" 退 出 " onClick="doCancel();">
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

</body>
</html>